

#ifndef __CE_MORPH_MESH_H__
#define __CE_MORPH_MESH_H__

#include <cegfx/ceexport.h>
#include <cegfx/igeometry.h>
#include <cegfx/imorphmesh.h>
#include <vector>

class CE_GFX_API ceMorphMesh : public iGeometry, iMorphMesh
{
	IQF_DECLARATION;
protected:
	std::vector<LPDIRECT3DVERTEXBUFFER9>	vertexBuffers;
	unsigned															numVertices;
	LPDIRECT3DINDEXBUFFER9								indexBuffer;
	unsigned															numTriangles;
	LPDIRECT3DVERTEXDECLARATION9					vertexDeclaration;
	unsigned stride;
	
	ceBoundingBox													boundingBox;

	unsigned															idx0, idx1;
	float																	interpol;
public:
	ceMorphMesh ();
	~ceMorphMesh ();

	void AddVertices (LPDIRECT3DVERTEXBUFFER9	vertexBuffer);
	void AddVertices (LPDIRECT3DVERTEXBUFFER9	vertexBuffer, unsigned numVertices);
	LPDIRECT3DVERTEXBUFFER9 GetVertexBuffer (unsigned idx);
	const LPDIRECT3DVERTEXBUFFER9 GetVertexBuffer (unsigned idx) const;
	unsigned GetNumberOfMorphFrames () const;
	unsigned GetNumVertices () const;

	void SetVertexDeclaration (LPDIRECT3DVERTEXDECLARATION9 declaration, unsigned stride);
	LPDIRECT3DVERTEXDECLARATION9 GetVertexDeclaration ();
	const LPDIRECT3DVERTEXDECLARATION9 GetVertexDeclaration () const;
	unsigned GetStride () const;

	void SetIndices (LPDIRECT3DINDEXBUFFER9 indexBuffer, unsigned numTriangles);
	LPDIRECT3DINDEXBUFFER9 GetIndexBuffer();
	const LPDIRECT3DINDEXBUFFER9 GetIndexBuffer() const;
	unsigned GetNumberOfTriangles () const;

	void Render (const ceRenderEnv& env);
	void Update (const ceUpdateEnv& env);
	const ceBoundingBox& GetBoundingBox () const;

	void SetMorphFrame (unsigned frame0, unsigned frame1, float interpol);

};



#endif /* ! __CE_MORPH_MESH_H__ */ 
